import {getArticleApi} from "../../../services/api"

export default {
  namespace: 'article',

  state: {
    data: {
      title: '',
      content:''
    },
  },

  effects: {
    *get({payload}, {call, put}) {
      const response = yield call(getArticleApi, payload);
      yield put({
        type: 'saveArticleData',
        payload: response,
      });
    },
  },

  reducers: {
    saveArticleData(state, action) {
      return {
        ...state,
        data: action.payload,
      };
    },
  }
}
